home *** CD-ROM | disk | FTP | other *** search
/ Aminet 19 / Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso / Aminet / comm / cnet / comparebbstext.lha / CompareBBSText next >
Text File  |  1997-03-22  |  8KB  |  162 lines

  1. /**************************************************************************\
  2.       $VER: Compare BBSText Files, v1.00 (22-Mar-97) by Dotoran!
  3. \**************************************************************************/
  4. options results;signal on SYNTAX;signal on ERROR;signal on IOERR
  5. a=sourceline(2);parse var a . ", "ver" ("vdate")" .;a=random(,,time("s"))
  6. tr=transmit;se=sendstring;gc=getchar;gu=getuser;gs=getscratch;mg=maygetchar
  7. a="rexxsupport.library";if ~show("l",a) then if ~addlib(a,0,-30) then exit
  8. parse source . . fp .;df=left(fp,max(lastpos('/',fp),lastpos(':',fp)))
  9. /****** SysOp Definable Variables *******************************************/
  10.                                     /* ALL FOUR CAN BE EDITED ONCE INSIDE   */
  11. oldfile="cnet:bbstext."             /* Location of OLD Stock BBSText file   */
  12. newfile="cnet:!bbstext_stock"       /* Location of NEW Stock BBSText file   */
  13. modfile="cnet:bbstext"              /* Location of YOUR Custom BBSText      */
  14. confile="cnet:bbstext.con"          /* The Converted BBSText path/filename  */
  15.  
  16. logging=2                           /* 0=Off, 1=Minimal, 2=Full             */
  17. logfile="SysData:Log/BBSTextDiff"   /* Log path/filename                    */
  18.  
  19. Llength=0   /* Maximum Line Length: 0-> Less than 1000 (Fastest Processing)
  20.                                     1-> Up to 2000
  21.                                     2-> Of ANY Length  (Slowest Processing) */
  22. /****** Start of Program Code Below; Hands Off! hehe ************************/
  23.  
  24. gu 1100645 ; editor=result /* Change to VisEd if not already set */
  25. if editor=0 then do;setobject "1";putuser 1100645;end;lf="0A"x
  26. changewhere "CompareBBSText" ; oldwh=result
  27. gu 2124557 ; lace=result /* Check Interlaced Setting */
  28. if lace=0 then do
  29.   se "n2   It is recommended that you run this program in Full Interlaced "
  30.   se "display mode. Your Interlace setting shows as being OFF right now. "
  31.   se "Some of the displays used in this program may scroll off your screen. "
  32.   se "You can opt to switch Full Interlaced mode right now. Press any key "
  33.   se "either after you have switched modes, or to continue in NonInterlaced "
  34.   se "mode.g1" ; end
  35.  
  36. tr "f1n1Compare CNet BBSText Files, "ver" last updated: "vdate"n1"
  37.  
  38. GETOLD:
  39.   se "Filename of the Old Version Original: L1305640 #"oldfile"}I4 30}"
  40.   gu 70;oldfile=result;if ~exists(oldfile) then do
  41.     tr "`"oldfile"' could NOT be found! <Key>g1";signal GETOLD;end
  42. GETNEW:
  43.   se "Filename of the New Version Original: L1305640 #"newfile"}I4 30}"
  44.   gu 70;newfile=result;if ~exists(newfile) then do
  45.     tr "`"newfile"' could NOT be found! <Key>g1";signal GETNEW;end
  46. GETMOD:
  47.   se "Filename of Your Modded Version File: L1305640 #"modfile"}I4 30}"
  48.   gu 70;modfile=result;if ~exists(modfile) then do
  49.     tr "`"modfile"' could NOT be found! <Key>g1";signal GETMOD;end
  50. GETCON:
  51.   se "Filename to Save the Converted  File: L1305640 #"confile"}I4 30}"
  52.   gu 70;confile=result;if exists(confile) then do
  53.     tr "`"newfile"' already exists! <Key>g1";signal GETCON;end
  54.  
  55. if logging>0 then do ; call open(l1,logfile,"W")
  56.   call writeln(l1,"BBSText Compare initiated on: "date()" at "time()lf);end
  57. call open(o1,oldfile,"R") ; call open(n1,newfile,"R")
  58. call open(m1,modfile,"R") ; call open(c1,confile,"W") ; tr "f1"
  59. do i=1 until eof(n1) ; se "sReading/Writing Line: "right(i,4)"u"
  60.   select
  61.     when Llength=0 then do;old=readln(o1);new=readln(n1);mod=readln(m1);end
  62.     when Llength=1 then do
  63.       old=readln(o1);if length(old)=1000 then do;a=readln(o1);old=old||a;end
  64.       new=readln(n1);if length(new)=1000 then do;a=readln(n1);new=new||a;end
  65.       mod=readln(m1);if length(mod)=1000 then do;a=readln(m1);mod=mod||a;end
  66.     end
  67.     otherwise do
  68.       a="";old="";do until length(a)<1000;a=readln(o1);old=old||a;end
  69.       a="";new="";do until length(a)<1000;a=readln(n1);new=new||a;end
  70.       a="";mod="";do until length(a)<1000;a=readln(m1);mod=mod||a;end
  71.     end
  72.   end
  73.   if old=new then do;call writeln(c1,mod);iterate;end
  74.   if logging>0 then call writeln(l1,"Line Differences Found in Line "i".")
  75.   if logging=2 then do
  76.     call writeln(l1,lf"From OLD Stock BBSText"lf||translate(old,"{\","")||lf)
  77.     call writeln(l1,"From NEW Stock BBSText"lf||translate(new,"{\","")||lf)
  78.     call writeln(l1,"From MODified  BBSText"lf||translate(mod,"{\","")||lf) ; end
  79.   tr "f1Line Differences Found in Line "i":n1"
  80.   tr "r1  Line "i" in your OLD Stock BBSText File... r0:n1" ; send old ; tr ; tr
  81.   tr "r1  Line "i" in your NEW Stock BBSText File... r0:n1" ; send new ; tr ; tr
  82.   tr "r1  Line "i" in your MODified  BBSText File... r0:n1" ; send mod ; tr ; tr
  83.   tr "r1  Writing to the Conversion File named... r0: "confile"n1"
  84.   se "(E)dit the line, or write the (O)ld, (M)odded, or [NEW] line: "
  85.   gc ; a=result
  86.   select
  87.     when a="O" then do;tr "Old";call writeln(c1,old)
  88.       call writeln(l1,"Wrote the OLD Stock BBSText Line to `"confile"'."lf);end
  89.     when a="M" then do;tr "Mod";call writeln(c1,mod)
  90.       call writeln(l1,"Wrote the MODified BBSText Line to `"confile"'."lf);end
  91.     when index("EOM",a)=0 then do;tr "New";call writeln(c1,new)
  92.       call writeln(l1,"Wrote the NEW Stock BBSText Line to `"confile"'."lf);end
  93.     otherwise do ; tr "Edit"
  94.       se " Load the (O)ld, (M)odded, or [NEW] line for further editing: "
  95.       gc ; a=result ; if a="O" then do;tr "Old";line=old;end
  96.       else if a="M" then do;tr "Mod";line=mod;end
  97.       else do;tr "New";line=new;end
  98.       call open(f1,"ram:cbt","W");call writeln(f1,line);call close(f1)
  99.       loadeditor "ram:cbt" ; calleditor 0 ; gu 1109865 ; st=result
  100.       /* st --> 1=saved, 0=empty, -1=aborted editor */
  101.       if st<1 then do
  102.         call seek(o1,-(length(old)+1))
  103.         call seek(n1,-(length(new)+1))
  104.         call seek(m1,-(length(mod)+1))
  105.         i=i-1 ; iterate i ; end
  106.       else saveeditor "ram:cbt" ; cleareditor
  107.       call open(f1,"ram:cbt","R") ; line=""
  108.         do until eof(f1) ; a=readln(f1)
  109.           line=line||a ; end ; line=strip(line,"t")
  110.       call close(f1)
  111.       tr "The Edited Line "i" for use in the `"confile"' File:n1"
  112.       send line ; tr ; tr
  113.       se "Is it OK to write this line now? [Yes]: "
  114.       gc ; a=result ; if a="N" then do ; tr "No."
  115.         call seek(o1,-(length(old)+1))
  116.         call seek(n1,-(length(new)+1))
  117.         call seek(m1,-(length(mod)+1))
  118.         i=i-1 ; iterate i ; end
  119.       tr "Yes" ; call writeln(c1,line)
  120.       if logging=2 then call writeln(l1,"Wrote this Edited Line to `"confile"':"lf||translate(line,"{\","")||lf)
  121.     end
  122.   end
  123. end i
  124. call close(c1) ; call close(m1)
  125. call close(n1) ; call close(o1)
  126.  
  127. /* If LineEd was originally set, change back to it before exiting. */
  128. if editor=0 then do;setobject "0";putuser 1100645;end
  129.  
  130. se "n1ReName `"modfile"' as `"modfile".old' now? [Yes]: "
  131. gc ; a=result ; if a="N" then do ; tr "No. Exiting..." ; signal DONE ; end
  132. tr "Yes!" ; address command "rename "modfile" "modfile".old"
  133. if logging>0 then call writeln(l1,"Renamed `"modfile"' to `"modfile".old'.")
  134.  
  135. se "ReName `"confile"' as `"modfile"' now? [Yes]: "
  136. gc ; a=result ; if a="N" then do ; tr "No. Exiting..." ; signal DONE ; end
  137. tr "Yes!" ; address command "rename "confile" "modfile
  138. if logging>0 then call writeln(l1,"Renamed `"confile"' to `"modfile"'.")
  139.  
  140. if upper(left(modfile,5))="CNET:" then do
  141.   se "ReLoad the BBSText file into your system? [Yes]: "
  142.   gc ; a=result ; if a="N" then do ; tr "No. Exiting..." ; signal DONE ; end
  143.   tr "Yes!" ; addkeys ("RT`")
  144.   if logging>0 then call writeln(l1,"Reloaded BBSText file!")
  145. end
  146.  
  147. DONE:
  148. tr "n1BBSText Compare is now complete!"
  149. if logging>0 then do
  150.   call writeln(l1,lf"BBSText Compare Completed on "date()" at "time()".")
  151.   call close(l1) ; end
  152.  
  153. changewhere oldwh
  154. exit
  155. SYNTAX:;ERROR:;IOERR:;e1="n1 Error: "rc" ("errortext(rc)")"
  156.   e2="  Line: "left(sigl,4)"File:";c="`"fp", "ver"'";e2=e2" "c;tr e1;tr e2
  157.   logentry e1;logentry e2;e=strip(translate(sourceline(sigl),"\{",""))
  158.   do while e~="";e3="Source: "left(e,37);tr e3;logentry e3;e=substr(e,38);end
  159.   bufferflush ; changewhere oldwh
  160. /**************************************************************************\
  161. \****************************************** Frontiers BBS (716)/823-9892 **/
  162.